﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Xml;

/// <summary>
/// The event venues as a list of venue
/// </summary>
public class Venues:List<Venue>
{
	public Venues(XmlDocument XmlDocument)
	{
        foreach (XmlElement item in XmlDocument.DocumentElement)
        {
            Venue v = new Venue(item);
            base.Add(v);
        }
    }
}
/// <summary>
/// The event venue
/// </summary>
public class Venue
{
    #region Venue Arguments
    /// <summary>
    /// The venue ID.
    /// </summary>
    public int ID { get; set; }
    /// <summary>
    /// The venue name.
    /// </summary>
    public string Name { get; set; }
    /// <summary>
    /// The venue address.
    /// </summary>
    public string Address { get; set; }
    /// <summary>
    /// The venue address (continued)
    /// </summary>
    public string Address2 { get; set; }
    /// <summary>
    /// The venue city
    /// </summary>
    public string City { get; set; }
    /// <summary>
    /// The venue state/province/county depending on the country
    /// </summary>
    public string Region { get; set; }
    /// <summary>
    /// The venue postal code
    /// </summary>
    public string PostalCode { get; set; }
    /// <summary>
    /// The venue country name
    /// </summary>
    public string Country { get; set; }
    /// <summary>
    /// he venue country code, in 2-letter ISO 3166 format (e.g., "US")
    /// </summary>
    public string CountryCode { get; set; }
    /// <summary>
    /// The venue GeoLocation in WGS84 (Longitude)
    /// </summary>
    public float Longitude { get; set; }
    /// <summary>
    /// The venue GeoLocation in WGS84 (Latitude)
    /// </summary>
    public float Latitude { get; set; }
    /// <summary>
    /// The venue GeoLocation in WGS84 (Latitude/Longitude)
    /// </summary>
    public string LatLong { get; set; }
    
    #endregion

    internal Venue(XmlElement XmlElement) { CreateVenuse(XmlElement); }
    public Venue(XmlDocument XmlDocument) { CreateVenuse(XmlDocument.DocumentElement); }

    private void CreateVenuse(XmlElement XmlElement)
    {
        foreach (XmlElement item in XmlElement)
        {
            switch (item.Name)
            {
                case "id":
                    this.ID = Convert.ToInt32(item.InnerText);
                    break;
                case "name":
                    this.Name = item.InnerText;
                    break;
                case "address":
                    this.Address = item.InnerText;
                    break;
                case "address_2":
                    this.Address2 = item.InnerText;
                    break;
                case "city":
                    this.City = item.InnerText;
                    break;
                case "region":
                    this.Region = item.InnerText;
                    break;
                case "postal_code":
                    this.PostalCode = item.InnerText;
                    break;
                case "country":
                    this.Country = item.InnerText;
                    break;
                case "country_code":
                    this.CountryCode = item.InnerText;
                    break;
                case "longitude":
                    this.Longitude = float.Parse(item.InnerText);
                    break;
                case "latitude":
                    this.Latitude = float.Parse(item.InnerText);
                    break;
                case "Lat-Long":
                    this.LatLong = item.InnerText;
                    break;
                default:
                    break;
            }
        }
    }

}
